// Card.cpp: implementation of the CCard class.
//
//////////////////////////////////////////////////////////////////////

#include "Card.h"
#include "math.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

#include "iface.h"



//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCard::Suit CCard::trump = UnknowSuit;

CCard::~CCard()
{

}

CCard::CCard( const CCard& _card )
{
	this->value = _card.GetValue();
	this->suit	= _card.GetSuit();
	this->face_down = _card.IsFaceDown();
//	std::cout << inf << "copy constructor, CCard(" << (int)this->suit << "," << (int)this->value << ")" << std::endl;
}

/*
	returns zero if values are equal
	returns negative for this.value less than parameter.value,
	returns positive for this.value greater than parameter.value

	return value is the difference between values
*/

int	CCard::CompareValue( const CCard& _card )
{
	return (int)this->value - (int)_card.value;
}

void CCard::Draw( unsigned int _x, unsigned int _y, bool draw_selected, unsigned char _width, unsigned char _height )
{
//    std::cout << inf << "CCard::Draw(" << _x << "," << _y << "," << draw_selected << "," << (int)_width << "," << (int)_height << ")" << std::endl;
//	this->DrawPlaceHolder( _x, _y );
	if( !face_down )
		CIface::DrawCard( this->suit, this->value, _x, _y );
	else
		CIface::DrawBack( _x, _y );
	
}

void CCard::DrawCursor( unsigned int _x, unsigned int _y )
{
//    std::cout << inf << "CCard::DrawCursor(" << _x << "," << _y << ")" << std::endl;
	
	CIface::DrawHand( _x, _y );
}

void CCard::DrawPlaceHolder( unsigned int _x, unsigned int _y )
{
//    std::cout << inf << "CCard::DrawPlaceHolder(" << _x << "," << _y << ")" << std::endl;
	CIface::DrawPlaceHolder( _x, _y );
}

bool CCard::Flip()
{
	return this->face_down = !this->face_down;
}

bool CCard::IsFaceDown() const
{
	return this->face_down;
}
